import axios from "axios";
import Qs from "qs";
export default {
    //开启命名空间
    namespaced: true,
    //<!-- 在.vue文件中通过this.$store.state.xxx来进行获取 -->
    state: {
        name: "袁晓迪",
        listdata: [],
        id: ""
    },
    getters: {
        newName(state) {
            return state.name + '的模块'
        }
    },
    mutations: {
        CHANGE_NAME(state) {
            state.name = '被修改了'
        },
        DETAIL(state, { res }) {
            state.listdata = res
        },

    },
    actions: {
        // detailto({ commit }) {
        //     var data1 = Qs.stringify({
        //         lawyerId: this.state.id,
        //     });
        //     axios.post("/lawyerMessage/findLawyerMessageByLawyerId", data1).then(res => {
        //         commit("DETAIL", { res: res.data })
        //         console.log(res)
        //     })
        // },
        detail({ commit }, id) {
            console.log('发起异步');
            localStorage.setItem("id", id)
            this.state.id = id;
            var data1 = Qs.stringify({
                lawyerId: this.state.id,
            });
            axios.post("/lawyerMessage/findLawyerMessageByLawyerId", data1).then(res => {
                commit("DETAIL", { res: res.data })
                console.log(res)
            })
        },
        refresh({ commit }) {
            var data1 = Qs.stringify({
                lawyerId: localStorage.getItem("id"),
            });
            axios.post("/lawyerMessage/findLawyerMessageByLawyerId", data1).then(res => {
                commit("DETAIL", { res: res.data })
                // console.log(res)
            })
        },


    },
};
